package com.web.transaction;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.TreatmentsDAO;
import com.domain.Treatments;
import com.service.TreatmentsService;
import com.util.AuthenticateHttpServlet;
import com.util.AuthenticateSession;

@WebServlet("/Transaction/TreatmentForm")
public class TreatmentSalesTransactionForm extends AuthenticateHttpServlet {

	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		AuthenticateSession session = (AuthenticateSession) request
				.getSession().getAttribute("authenticateSession");
		request.setAttribute("user", session);
		if (session != null) {
			TreatmentsService service = new TreatmentsService();
			List<Treatments> list = service.getAllTreatment();
			request.setAttribute("user", session);
			request.setAttribute("treatment", list);
			request.getRequestDispatcher(
					"/WEB-INF/jsp/treatmentTransaction.jsp").forward(request,
					response);
		} else {
			request.getRequestDispatcher("/login.jsp").forward(request,
					response);
		}
	}
}
